package com.example.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;

import java.time.LocalDateTime;

/**
 * @description spring batch listener
 * @author: ruanchengzhi
 * @create: 2021-07-29 19:54
 **/
public class BatchJobListener implements JobExecutionListener {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public void beforeJob(JobExecution jobExecution) {
        logger.info("[op:batchJobListener] beforeJob [{}] systemTime [{}]", jobExecution.getJobId(), LocalDateTime.now());
    }

    @Override
    public void afterJob(JobExecution jobExecution) {
        logger.info("[op:batchJobListener] afterJob [{}] systemTime [{}]", jobExecution.getJobId(),LocalDateTime.now());
    }
}
